Micron Document
🌎 rns.kin.earth git 🌍

Node / dev / reticulum / commits / 503f475

Commit 503f475ca5ee44e8a02fa82d077e422f64848f85


Parents : 8506118
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-01-11T03:12:31+01:00

Read link MTU from link request packet

Changes

3 files changed, 16 insertions(+), 6 deletions(-)

M RNS/Link.py +14 -4

Diff

diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py
index f007cc9f..9dff4c26 100644
--- a/RNS/Interfaces/LocalInterface.py
+++ b/RNS/Interfaces/LocalInterface.py
@@ -59,7 +59,7 @@ class LocalClientInterface(Interface):
# TODO: Remove at some point
# self.rxptime = 0
- self.HW_MTU = 1064
+ self.HW_MTU = 32768
self.online = False

diff --git a/RNS/Interfaces/TCPInterface.py b/RNS/Interfaces/TCPInterface.py
index 563e38b6..bd601494 100644
--- a/RNS/Interfaces/TCPInterface.py
+++ b/RNS/Interfaces/TCPInterface.py
@@ -96,7 +96,7 @@ class TCPClientInterface(Interface):
connect_timeout = c.as_int("connect_timeout") if "connect_timeout" in c else None
max_reconnect_tries = c.as_int("max_reconnect_tries") if "max_reconnect_tries" in c else None
- self.HW_MTU = 1064
+ self.HW_MTU = 32768
self.IN = True
self.OUT = False

diff --git a/RNS/Link.py b/RNS/Link.py
index c53fb959..f90adadc 100644
--- a/RNS/Link.py
+++ b/RNS/Link.py
@@ -68,8 +68,9 @@ class Link:
Timeout for link establishment in seconds per hop to destination.
"""
- TRAFFIC_TIMEOUT_MIN_MS = 5
- TRAFFIC_TIMEOUT_FACTOR = 6
+ LINK_MTU_SIZE = 3
+ TRAFFIC_TIMEOUT_MIN_MS = 5
+ TRAFFIC_TIMEOUT_FACTOR = 6
KEEPALIVE_TIMEOUT_FACTOR = 4
"""
RTT timeout factor used in link timeout calculation.
@@ -108,14 +109,22 @@ class Link:
@staticmethod
def validate_request(owner, data, packet):
- if len(data) == (Link.ECPUBSIZE):
+ if len(data) == Link.ECPUBSIZE or len(data) == Link.ECPUBSIZE+Link.LINK_MTU_SIZE:
try:
link = Link(owner = owner, peer_pub_bytes=data[:Link.ECPUBSIZE//2], peer_sig_pub_bytes=data[Link.ECPUBSIZE//2:Link.ECPUBSIZE])
link.set_link_id(packet)
+
+ if len(data) == Link.ECPUBSIZE+Link.LINK_MTU_SIZE:
+ try:
+ link.mtu = (ord(a[Link.ECPUBSIZE]) << 16) + (ord(a[Link.ECPUBSIZE+1]) << 8) + (ord(a[Link.ECPUBSIZE+2]))
+ except Exception as e:
+ link.mtu = Reticulum.MTU
+
link.destination = packet.destination
link.establishment_timeout = Link.ESTABLISHMENT_TIMEOUT_PER_HOP * max(1, packet.hops) + Link.KEEPALIVE
link.establishment_cost += len(packet.raw)
- RNS.log("Validating link request "+RNS.prettyhexrep(link.link_id), RNS.LOG_VERBOSE)
+ RNS.log(f"Validating link request {RNS.prettyhexrep(link.link_id), RNS.LOG_VERBOSE}")
+ RNS.log(f"Link MTU configured to {RNS.prettysize(link.mtu)}", RNS.LOG_EXTREME)
RNS.log(f"Establishment timeout is {RNS.prettytime(link.establishment_timeout)} for incoming link request "+RNS.prettyhexrep(link.link_id), RNS.LOG_EXTREME)
link.handshake()
link.attached_interface = packet.receiving_interface
@@ -142,6 +151,7 @@ class Link:
if destination != None and destination.type != RNS.Destination.SINGLE:
raise TypeError("Links can only be established to the \"single\" destination type")
self.rtt = None
+ self.mtu = Reticulum.MTU
self.establishment_cost = 0
self.establishment_rate = None
self.callbacks = LinkCallbacks()

Served by rngit 1.5.2 - Generated in 0.07s